package com.healthy.junit;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.apache.commons.collections.map.HashedMap;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.alibaba.fastjson.JSONObject;
import com.healthy.entity.YgUsers;
import com.healthy.mapper.YgUsersMapper;
import com.healthy.service.YgUsersService;

//import com.healthy.util.MyBatisUtil;

@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
//RunWith的value属性指定以spring test的SpringJUnit4ClassRunner作为启动类 [如果不指定启动类，默认启用的junit中的默认启动类]
@RunWith(value = SpringJUnit4ClassRunner.class)
public class junit {
	
//	public static void main(String[] args) {
////		System.out.println("方法测试：");
////		login1();
//		login2();
//	}

	@Autowired
	private  YgUsersService YgUsersService;
	@Autowired
	private  SqlSessionFactory sessionFactory;
	
	@Test
	public  void login2(){
//		System.out.println("方法测试：");
		//JSONObject的方式进行连接
//		JSONObject json = YgUsersService.userLogin("zhangsan", "123456");
//		System.out.println(json.toString());
		//System.out.println(sessionFactory);
		
		//map集合转换成list集合
//		Map<Integer,String> map=new HashMap<>();
//		map.put(1, "2");
//		map.put(2, "233");
//		map.put(3, "33");
//		List<Integer> list=new ArrayList<>(map.keySet());
//		List<String> lists=new ArrayList<>(map.values());
//		System.out.println(list);
//		System.out.println(lists);
		
		//Java随机数的生成
//		SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd");
//		SimpleDateFormat time = new SimpleDateFormat("HHmmss");	
//		String tradeDate = date.format(new Date());
//		String tradeTime = time.format(new Date());
//		String no = tradeDate+tradeTime;
		//生成一个6位随机数	            
		int radom = new Random().nextInt(999999);
		System.out.println("radom:"+radom);
		String str = "YG"  + radom;
		System.out.println("str:"+str);
		//对该随机数进行扩展
//		if (radom < 100000) {
//			radom += 100000;
//			}
//		String str = "L" + no + radom;
//		System.out.println("str:"+str);
	
			
	}
	

	
}

